import configparser
import os

from compact import project_paths


def get_config(file_path):
    '''
    获取配置文件
    '''
    config = configparser.ConfigParser()
    config.read(file_path)
    return config


def is_tesla_env():
    pass

def get_pytest_config():
    '''
    获取pytest配置文件
    '''
    # 根据tesla的依赖仓库判断是否为巡检tesla环境,若为tesla环境,读取pytest_tesla.ini
    if is_tesla_env():
        pytest_config_path = os.path.join(project_paths.project_path, 'pytest_tesla.ini')
    else:
        pytest_config_path = os.path.join(project_paths.project_path, 'pytest.ini')
    return get_config(pytest_config_path)


if __name__ == "__main__":
    def test_get_pytest_config():
        res = get_pytest_config().get("global", "need_setup")
        print(type(res))
        print(res)
        reruns = int(get_pytest_config().get("global", "reruns"))
        print(reruns)


    test_get_pytest_config()


    def test_is_tesla_env():
        print(is_tesla_env())


    test_is_tesla_env()